/*  File Name	: EngineService.h
 *  Author		: Pang Jiacai
 *	 E-mail		: 823960168@qq.com
 *  Created on	: 2012-7-2
 *  Description:
 */

#ifndef ENGINESERVICE_H_
#define ENGINESERVICE_H_
#include "Service.h"

class EngineMonitor;

class EngineService:virtual public ServiceEX<EngineMonitor>
{
private:
	typedef ServiceEX<EngineMonitor> super;

public:
	EngineService(int p=0);

	virtual ~EngineService();

	virtual int open(void * =0);

	virtual int handle_input(int fd = INVALID_HANDLER);

	virtual int handle_output(int fd = INVALID_HANDLER);

	virtual int handle_timeout(int handle);

	virtual int handle_close(int handle = INVALID_HANDLER,
			ReactorMask = EventHandler::ALL_MASK);

	virtual int recv_msg(const int limit_size = 1024*60);

	virtual int send_msg(MessageBlock *mb,int len,int flag=0);

	//int recycle(EngineService *s);

	void reset(void);

	std::string name(void);

	const int peer_svc_id(void);

	int gate_id(void);

	void gate_id(int gate_id);

private:
	int peer_svc_id_;
	int gate_id_;
};

#endif /* ENGINESERVICE_H_ */
